//
//  MyCarButtomView.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/15.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "MyCarButtomView.h"
#import "CommonMacro.h"
@implementation MyCarButtomView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self initWithSubviews];
        self.backgroundColor = UIColorWithRGBA(255, 255, 255, 1);
    }
    return self;
}

- (void)initWithSubviews
{
    CGFloat labelX = SCREEN_WIDTH*0.2;
    CGFloat labelY = 10;
    CGFloat labelW = SCREEN_WIDTH*0.18;
    CGFloat labelH = 40;
    
    //汇集购买数量
    self.numLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10,SCREEN_WIDTH*0.09, 40)];
    self.numLabel.layer.borderColor = UIColorWithRGBA(208, 208, 208, 1).CGColor;
    self.numLabel.layer.cornerRadius = 3;
    self.numLabel.clipsToBounds = YES;
    self.numLabel.layer.borderWidth = 1;
    [self  addSubview:self.numLabel];
    

    //总计数量
    self.totalLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelX,labelY,labelW,labelH)];
    self.totalLabel.text = @"总计：";
    self.totalLabel.font = [UIFont fontWithName:nil size:18];
    self.totalLabel.textColor = UIColorWithRGBA(136, 136, 136, 1);
    [self addSubview:self.totalLabel];
    
    //price label
    self.priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.totalLabel.frame.size.width+self.totalLabel.frame.origin.x, labelY, labelW*1.6, labelH)];
    self.priceLabel.text = @"￥369";
    self.priceLabel.textColor = UIColorWithRGBA(240, 82, 39, 1);
    self.priceLabel.font = [UIFont fontWithName:nil size:20];
    [self addSubview:self.priceLabel];
    self.priceLabel.textColor = UIColorWithRGBA(238, 83, 41, 1);
    
    //结算
    self.accountButton = [[UIButton alloc] initWithFrame:CGRectMake(self.priceLabel.frame.size.width+self.frame.origin.x+self.totalLabel.frame.size.width+self.totalLabel.frame.origin.x, labelY, labelW*1.5, labelH)];
    self.accountButton.backgroundColor = UIColorWithRGBA(239, 83, 38, 1);
    self.accountButton.layer.cornerRadius = 3;
    self.accountButton.clipsToBounds = YES;
    [self.accountButton setTitle:@"结 算" forState:UIControlStateNormal];
    [self addSubview:self.accountButton];
    [self.accountButton addTarget:self action:@selector(helpMeClick) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark 结算按钮点击事件
- (void)helpMeClick
{
    if ([self.delegate respondsToSelector:@selector(accountButton)]) {
        [self.delegate accountButton];
    }
}
@end
